home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "DSOSampleCode"
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- '
- ' Sales cube from scratch.bas - contains the basic functions for creating a
- ' cube.
- '
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Option Explicit
- Option Compare Text
-
-
- ' module level variables
- Public m_dsoServer As DSO.Server
- Public m_dsoDatabase As DSO.MDStore
- Public m_dsoCube As DSO.MDStore
-
-
- '
- ' Initialize - initialize the sample application
- '
- '
- Public Sub Initialize()
- ' If the DSO server object has already been in use
- ' then call CloseServer method
- ' NOTE: CloseServer method releases all of the resources
- ' acquired by DSO. It is important to call this
- ' method when the DSO server object is not needed
- ' any longer
- If Not m_dsoServer Is Nothing Then
- m_dsoServer.CloseServer
- End If
- End Sub
-
- '
- ' ConnectToServer - create and connect to the DSO server
- '
- Public Sub ConnectToServer()
- ' create an instance of the server object
- Dim dsoServer As DSO.Server
- Set dsoServer = New DSO.Server
-
- ' connect to the server
- On Error GoTo Err_Connect
- dsoServer.Connect frmMain.txtServerName
-
- ' store the reference to the server object
- ' so that other methods can use it
- Set m_dsoServer = dsoServer
-
- Exit Sub
-
- Err_Connect:
- ' Failed to connect to the server.
- ' Possible reasons:
- ' - the Microsoft SQL Server OLAP Server is not running
- ' - the machine on which the OLAP Server is running cannot be reached
- ' - the machine on which DSO application is running is not connected
- ' to the network
- ' - you are not a member of the OLAP Administrators user group on the
- ' server machine
-
- MsgBox "Failed to connect to the server" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateDatabase - create new database
- '
- Public Sub CreateDatabase()
- ' call the database "DSOSample"
- Dim sDatabaseName As String
- sDatabaseName = "DSOSample"
-
- ' check if a database with the same name
- ' already exists on the server
- If m_dsoServer.MDStores.Find(sDatabaseName) Then
-
- ' delete the existing database
- On Error GoTo Err_DeleteDatabase
- m_dsoServer.MDStores.Remove sDatabaseName
- End If
-
- ' create the new database
- On Error GoTo Err_CreateDatabase
- Dim dsoDatabase As DSO.MDStore
- Set dsoDatabase = m_dsoServer.MDStores.AddNew(sDatabaseName)
-
- ' set the database description
- dsoDatabase.Description = "SampleDSO database contains Warehouse cube."
-
- ' create a few custom properties
- dsoDatabase.CustomProperties.Add "Marin Bezic", "Creator", vbString
- dsoDatabase.CustomProperties.Add Date, "Date created", vbDate
-
- ' save the database definition in the OLAP server's metadata repository
- On Error GoTo Err_Update
- dsoDatabase.Update
-
- ' store the reference to the database object
- ' so that other methods can use it
- Set m_dsoDatabase = dsoDatabase
-
- Exit Sub
-
- Err_DeleteDatabase:
- ' Failed to remove the database from the server.
- ' Possible reasons:
- ' - the OLAP server is not running or unreachable
- ' - the database is being used by another DSO application
-
- Err_CreateDatabase:
- ' Failed to create the database on the server.
- ' Possible reasons:
- ' - the OLAP server is not running or unreachable
- ' - the DSO server object is being locked by another DSO application
- ' the server object is locked while AddNew method is executing on
- ' the server's MDStores collection
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the database definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO database object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create database failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateDatasource - create the new datasource
- '
- Public Sub CreateDatasource()
- ' create the new datasource that points to the
- ' sample FoodMart database
- On Error GoTo Err_CreateDatasource
- Dim dsoDatasource As DSO.DataSource
- Set dsoDatasource = m_dsoDatabase.DataSources.AddNew("Foodmart Sample Database")
-
- ' set the OleDB connection string
- ' the connection string is used to establish the connection
- ' to the relational database that contains the dimension and
- ' fact tables
- ' we will use OleDB provider for Jet
- dsoDatasource.ConnectionString = _
- "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\OLAP Services\Samples\FoodMart.mdb;JET OLEDB:SFP=True;"
-
- ' save the datasource definition in the metadata repository
- On Error GoTo Err_Update
- dsoDatasource.Update
-
- Exit Sub
-
- Err_CreateDatasource:
- ' Failed to create the datasource.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, ...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the datasource definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO datasource object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create datasource failed" & vbCrLf & Err.Description
- End Sub
-
- '
- ' CreateDimensionStore - create the Store dimension
- '
- ' NOTE: the Store dimension is an example of a dimension
- ' that is based on one dimension table (star schema)
- '
- Public Sub CreateDimensionStore()
- ' create the Store dimension in the database's
- ' Dimensions collection
- On Error GoTo Err_Create
- Dim dsoDimension As DSO.Dimension
- Set dsoDimension = m_dsoDatabase.Dimensions.AddNew("Store")
-
- ' set the dimension description
- dsoDimension.Description = "The stores hierarchy"
-
- ' set the dimension's datasource
- Set dsoDimension.DataSource = m_dsoDatabase.DataSources("Foodmart Sample Database")
-
- ' get the quoting characters from the datasource
- Dim sLQuote As String, sRQuote As String
- sLQuote = dsoDimension.DataSource.OpenQuoteChar
- sRQuote = dsoDimension.DataSource.CloseQuoteChar
-
- ' set the dimension type
- dsoDimension.DimensionType = dimRegular
-
- ' set the comma separated list of the dimension tables
- ' NOTE: the tables must be quoted
- ' the Store dimension uses only the "store" table
- dsoDimension.FromClause = sLQuote & "store" & sRQuote
-
- ' define the joins between tables used by this dimension
- ' the format of this property is
- ' (table1.columnX = table2.columnY) and (table2.columnZ = table3.columnW)
- ' since the Store dimension is based on only one table, we have no joins
- dsoDimension.JoinClause = ""
-
-
- '
- ' create dimension levels
- '
- Dim dsoLevel As DSO.Level
-
- '
- ' create the All level
- ' the All level is the top-most level in the dimension hierarcy
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("All")
-
- ' set the level type
- dsoLevel.LevelType = levAll
-
- ' the All level has only one member
- ' set the MemberKeyColumn of the All level to a constant
- ' this constant is at the same time the name of that single member
- dsoLevel.MemberKeyColumn = "All Stores"
-
- '
- ' create the Store Country level
- ' the Store Country level contains all of the countries
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Store Country")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' define which column contains the level member keys
- ' sLQuote and sRQuote are obtained from dsoDimension.Datasource
- ' NOTE: the tables and columns must be quoted using the quoting
- ' characters obtained from the dimension's datasource
- dsoLevel.MemberKeyColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_country" & sRQuote
-
- ' tell DSO how many members this level has
- ' this information will be used during the design of aggregations
- ' when determining the optimal set of aggregations
- ' there are 3 countries in the "store" table: Mexico, Canada, and USA
- dsoLevel.EstimatedSize = 3
-
- ' this level contains unique members
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the type and maximum size of the members keys
- ' NOTE: the ColumnSize property needs to be set only for
- ' levels that have string members
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 6 ' the longest members ("Mexico", "Canada")
- ' can fit in 6 characters
-
- ' specify how should the level members be ordered
- ' we want the countries ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Store State level
- ' the Store State level contains all of the states
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Store State")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "store_state" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_state" & sRQuote
-
- ' there are 10 distinct states in the "store" table
- dsoLevel.EstimatedSize = 10
-
- ' this level contains unique members,
- ' i.e. no state appears in more than one country
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 9 ' the longest member ("Zacatecas")
- ' can fit in 9 characters
-
- ' we want the states ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Store City level
- ' the Store City level contains all of the cities
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Store City")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "store_city" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_city" & sRQuote
-
- ' there are 23 distinct cities in the "store" table
- dsoLevel.EstimatedSize = 23
-
- ' this level contains unique members,
- ' i.e. no city appears in more than one state
- ' NOTE: this is often not the case,
- ' for example: Portland (Oregon) and Portland (Maine)
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 13 ' the longest member ("San Francisco")
- ' can fit in 13 characters
-
- ' we want the cities ordered by Name
- dsoLevel.Ordering = orderName
-
-
- '
- ' create the Store Name level
- ' the Store Name level contains all of the individual stores
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Store Name")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "store_id" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_id" & sRQuote
-
- ' we will use column "store_name" for member names
- dsoLevel.MemberNameColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_name" & sRQuote
-
- ' there are 24 distinct stores in the "store" table
- dsoLevel.EstimatedSize = 24
-
- ' this level contains unique members,
- ' i.e. no store appears in more than one city
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the data type of the level members keys
- ' since this level has numeric member keys, we do not need to set the ColumnSize
- dsoLevel.ColumnType = adInteger
-
- ' we want the stores ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the member properties for the Store Name level
- '
- Dim dsoMemberProperty As DSO.MemberProperty
-
- ' create a member property containing the name of the store manager
- Set dsoMemberProperty = dsoLevel.MemberProperties.AddNew("Store Manager")
- ' set the column which contains the names of the managers
- dsoMemberProperty.SourceColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_manager" & sRQuote
-
- ' create a member property containing the type of the store
- Set dsoMemberProperty = dsoLevel.MemberProperties.AddNew("Store Type")
- ' set the column which contains the store type
- dsoMemberProperty.SourceColumn = sLQuote & "store" & sRQuote & "." & _
- sLQuote & "store_type" & sRQuote
-
- ' save the dimension definition in the metadata repository
- On Error GoTo Err_Update
- dsoDimension.Update
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the dimension definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO dimension object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create dimension Store failed" & vbCrLf & Err.Description
- End Sub
-
- '
- ' CreateDimensionTime - create the Time dimension
- '
- ' NOTE: the Time dimension is an example of a time dimension
- ' that is based on multiple time columns (year, quarter, month)
- '
- Public Sub CreateDimensionTime()
- ' create the Time dimension in the database's
- ' Dimensions collection
- On Error GoTo Err_Create
- Dim dsoDimension As DSO.Dimension
- Set dsoDimension = m_dsoDatabase.Dimensions.AddNew("Time")
-
- ' set the dimension description
- dsoDimension.Description = "The time hierarchy"
-
- ' set the dimension's datasource
- Set dsoDimension.DataSource = m_dsoDatabase.DataSources("Foodmart Sample Database")
-
- ' get the quoting characters from the datasource
- Dim sLQuote As String, sRQuote As String
- sLQuote = dsoDimension.DataSource.OpenQuoteChar
- sRQuote = dsoDimension.DataSource.CloseQuoteChar
-
- ' set the dimension type to time dimension
- ' NOTE: this is important as it enables the OLAP server to
- ' apply time functions to members of this dimension
- dsoDimension.DimensionType = dimTime
-
- ' set the comma separated list of the dimension tables
- ' NOTE: the tables must be quoted
- ' the Time dimension uses only the "time_by_day" table
- dsoDimension.FromClause = sLQuote & "time_by_day" & sRQuote
-
- ' define the joins between tables used by this dimension
- ' the format of this property is
- ' (table1.columnX = table2.columnY) and (table2.columnZ = table3.columnW)
- ' since the Time dimension is based on only one table, we have no joins
- dsoDimension.JoinClause = ""
-
-
- '
- ' create dimension levels
- '
- Dim dsoLevel As DSO.Level
-
- '
- ' create the All level
- ' the All level is the top-most level in the dimension hierarcy
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("All")
-
- ' set the level type
- dsoLevel.LevelType = levAll
-
- ' the All level has only one member
- ' set the MemberKeyColumn of the All level to a constant
- ' this constant is at the same time the name of that single member
- dsoLevel.MemberKeyColumn = "All Years"
-
- '
- ' create the Year level
- ' the Year level contains all of the years
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Year")
-
- ' set the level type
- dsoLevel.LevelType = levTimeYears
-
- ' define which column contains the level member keys
- ' sLQuote and sRQuote are obtained from dsoDimension.Datasource
- ' NOTE: the tables and columns must be quoted using the quoting
- ' characters obtained from the dimension's datasource
- ' NOTE: the alternative member for the year level can be
- ' DatePart('yyyy',"time_by_day"."the_date")
- dsoLevel.MemberKeyColumn = sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_year" & sRQuote
-
- ' tell DSO how many members this level has
- ' this information will be used during the design of aggregations
- ' when determining the optimal set of aggregations
- ' there are 2 years in the "time_by_day" table: 1997 and 1998
- dsoLevel.EstimatedSize = 2
-
- ' this level contains unique members
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the data and maximum size of the members keys
- ' NOTE: the ColumnSize property needs to be set only for
- ' levels that have string members
- dsoLevel.ColumnType = adSmallInt
-
- ' specify how should the level members be ordered
- ' we want the countries ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Quarter level
- ' the Quarter level contains all of the quarters
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Quarter")
-
- ' set the level type
- dsoLevel.LevelType = levTimeQuarters
-
- ' "quarter" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "quarter" & sRQuote
-
- ' there are 8 distinct quarters in the "time_by_day" table
- ' 4 belong to 1997, and 4 belong to 1998
- dsoLevel.EstimatedSize = 8
-
- ' this level DOES NOT contains unique members
- ' ex. Quarter 1 appears both in year 1997 and 1998
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 2 ' quarters are represented as Q1, Q2, ...
- ' they can fit in 2 characters
-
- ' we want the quarters ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Month level
- ' the Month level contains all of the months
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Month")
-
- ' set the level type
- dsoLevel.LevelType = levTimeMonths
-
- ' "month_of_year" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "month_of_year" & sRQuote
-
- ' we can use "the_month" column for names of the members (January, February, ...)
- dsoLevel.MemberNameColumn = sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_month" & sRQuote
-
- ' there are 24 distinct months in the "time_by_day" table
- ' 12 belong to 1997, and 12 belong to 1998
- dsoLevel.EstimatedSize = 24
-
- ' this level DOES NOT contain unique members,
- ' ex. January appears both in 1997 and 1998
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adSmallInt
-
- ' we want the months ordered by Key (1, 2, 3, ...)
- ' rather than by name (April, August, ...)
- dsoLevel.Ordering = orderKey
-
-
- ' save the dimension definition in the metadata repository
- On Error GoTo Err_Update
- dsoDimension.Update
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the dimension definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO dimension object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create dimension Time failed" & vbCrLf & Err.Description
- End Sub
-
- '
- ' CreateDimensionTimeFromDateTimeColumnFromDateTimeColumn - create the Time dimension
- ' based on the DateTime column
- '
- ' NOTE: this dimension is an example of how to create a time dimension
- ' by parsing the TimeDate column
- ' This rutine will work only with Access (Jet) databases since
- ' it utilizes Jet specific Date/Time functions
- Public Sub CreateDimensionTimeFromDateTimeColumn()
- ' create the Time dimension in the database's
- ' Dimensions collection
-
- On Error GoTo Err_Create
- Dim dsoDimension As DSO.Dimension
- Set dsoDimension = m_dsoDatabase.Dimensions.AddNew("Time from 1 column")
-
- ' set the dimension's datasource
- Set dsoDimension.DataSource = m_dsoDatabase.DataSources("Foodmart Sample Database")
-
- ' get the quoting characters from the datasource
- Dim sLQuote As String, sRQuote As String
- sLQuote = dsoDimension.DataSource.OpenQuoteChar
- sRQuote = dsoDimension.DataSource.CloseQuoteChar
-
- ' set the dimension type to time dimension
- ' NOTE: this is important as it enables the OLAP server to
- ' apply time functions to members of this dimension
- dsoDimension.DimensionType = dimTime
-
- ' set the comma separated list of the dimension tables
- ' NOTE: the tables must be quoted
- ' the Time dimension uses only the "time_by_day" table
- dsoDimension.FromClause = sLQuote & "time_by_day" & sRQuote
-
- ' define the joins between tables used by this dimension
- ' the format of this property is
- ' (table1.columnX = table2.columnY) and (table2.columnZ = table3.columnW)
- ' since the Time dimension is based on only one table, we have no joins
- dsoDimension.JoinClause = ""
-
-
- '
- ' create dimension levels
- '
- Dim dsoLevel As DSO.Level
-
- '
- ' create the All level
- ' the All level is the top-most level in the dimension hierarcy
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("All")
-
- ' set the level type
- dsoLevel.LevelType = levAll
-
- ' the All level has only one member
- ' set the MemberKeyColumn of the All level to a constant
- ' this constant is at the same time the name of that single member
- dsoLevel.MemberKeyColumn = "All Years"
-
- '
- ' create the Year level
- ' the Year level contains all of the years
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Year")
-
- ' set the level type
- dsoLevel.LevelType = levTimeYears
-
- ' define which column contains the level member keys
- ' NOTE: we are using DatePart function to extract the year
- ' from the DateTime column ("the_date")
- dsoLevel.MemberKeyColumn = "DatePart('yyyy'," & _
- sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_date" & sRQuote & _
- ")"
-
- ' tell DSO how many members this level has
- ' there are 2 years in the "time_by_day" table: 1997 and 1998
- dsoLevel.EstimatedSize = 2
-
- ' this level contains unique members
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the data and maximum size of the members keys
- ' NOTE: the ColumnSize property needs to be set only for
- ' levels that have string members
- dsoLevel.ColumnType = adSmallInt
-
- ' specify how should the level members be ordered
- ' we want the countries ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Quarter level
- ' the Quarter level contains all of the quarters
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Quarter")
-
- ' set the level type
- dsoLevel.LevelType = levTimeQuarters
-
- ' "quarter" column contains members for this level
- ' NOTE: we are using DatePart function to extract the quarter
- ' from the DateTime column ("the_date")
- dsoLevel.MemberKeyColumn = "DatePart('q'," & _
- sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_date" & sRQuote & _
- ")"
-
- ' lets give the quarter members nice names by setting the
- ' MemberNameColumn property of this level
- ' NOTE: if we do not set the MemberNameColumn, member keys will
- ' be used also as member names
- dsoLevel.MemberNameColumn = "'Quarter ' + Format(" & _
- "DatePart('q'," & _
- sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_date" & sRQuote & _
- ")" & _
- ")"
-
- ' there are 8 distinct quarters in the "time_by_day" table
- ' 4 belong to 1997, and 4 belong to 1998
- dsoLevel.EstimatedSize = 8
-
- ' this level DOES NOT contains unique members
- ' ex. Quarter 1 appears both in year 1997 and 1998
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 2 ' quarters are represented as Q1, Q2, ...
- ' they can fit in 2 characters
-
- ' we want the quarters ordered by Name
- dsoLevel.Ordering = orderName
-
- '
- ' create the Month level
- ' the Month level contains all of the months
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Month")
-
- ' set the level type
- dsoLevel.LevelType = levTimeMonths
-
- ' "month_of_year" column contains members for this level
- dsoLevel.MemberKeyColumn = "DatePart('m'," & _
- sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_date" & sRQuote & _
- ")"
-
- ' get the month names (January, February, ...)
- ' we can use the Format$ function to get the full month name
- dsoLevel.MemberNameColumn = "Format(" & _
- sLQuote & "time_by_day" & sRQuote & "." & _
- sLQuote & "the_date" & sRQuote & _
- ", 'mmmm')"
-
- ' there are 24 distinct months in the "time_by_day" table
- ' 12 belong to 1997, and 12 belong to 1998
- dsoLevel.EstimatedSize = 24
-
- ' this level DOES NOT contain unique members,
- ' ex. January appears both in 1997 and 1998
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adSmallInt
-
- ' we want the months ordered by Key (1, 2, 3, ...)
- ' rather than by name (April, August, ...)
- dsoLevel.Ordering = orderKey
-
-
- ' save the dimension definition in the metadata repository
- On Error GoTo Err_Update
- dsoDimension.Update
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the dimension definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO dimension object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create dimension Time failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateDimensionProduct - create the Product dimension
- '
- ' NOTE: the Product dimension is an example of a snowflake dimension
- ' (dimension based on multiple tables)
- '
- Public Sub CreateDimensionProduct()
- ' create the Product dimension in the database's
- ' Dimensions collection
- On Error GoTo Err_Create
- Dim dsoDimension As DSO.Dimension
- Set dsoDimension = m_dsoDatabase.Dimensions.AddNew("Product")
-
- ' set the dimension description
- dsoDimension.Description = "The Product hierarchy"
-
- ' set the dimension's datasource
- Set dsoDimension.DataSource = m_dsoDatabase.DataSources("Foodmart Sample Database")
-
- ' get the quoting characters from the datasource
- Dim sLQuote As String, sRQuote As String
- sLQuote = dsoDimension.DataSource.OpenQuoteChar
- sRQuote = dsoDimension.DataSource.CloseQuoteChar
-
- ' set the dimension type
- dsoDimension.DimensionType = dimRegular
-
- ' set the comma separated list of the dimension tables
- ' NOTE: the tables must be quoted
- ' the Product dimension uses "product" and "product_class" tables
- dsoDimension.FromClause = sLQuote & "product" & sRQuote & _
- ", " & _
- sLQuote & "product_class" & sRQuote
-
- ' define the joins between tables used by this dimension
- ' the two product tables are joined by "product_class_id" column
- dsoDimension.JoinClause = "(" & sLQuote & "product" & sRQuote & "." & _
- sLQuote & "product_class_id" & sRQuote & _
- " = " & _
- sLQuote & "product_class" & sRQuote & "." & _
- sLQuote & "product_class_id" & sRQuote & ")"
-
- '
- ' create dimension levels
- '
- Dim dsoLevel As DSO.Level
-
- '
- ' create the All level
- ' the All level is the top-most level in the dimension hierarcy
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("All")
-
- ' set the level type
- dsoLevel.LevelType = levAll
-
- ' the All level has only one member
- ' set the MemberKeyColumn of the All level to a constant
- ' this constant is at the same Product the name of that single member
- dsoLevel.MemberKeyColumn = "All Products"
-
-
- '
- ' create the Product Family level
- ' this level contains aggregates all products
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Product Family")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' define which column contains the level member keys
- ' sLQuote and sRQuote are obtained from dsoDimension.Datasource
- ' NOTE: the tables and columns must be quoted using the quoting
- ' characters obtained from the dimension's datasource
- dsoLevel.MemberKeyColumn = sLQuote & "product_class" & sRQuote & "." & _
- sLQuote & "product_family" & sRQuote
-
- ' tell DSO how many members this level has
- ' this information will be used during the design of aggregations
- ' when determining the optimal set of aggregations
- ' there are 3 product families in the
- ' "product_class" table: Drink, Food, and Non_Consumable
- dsoLevel.EstimatedSize = 3
-
- ' this level contains unique members
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the type and maximum size of the level members keys
- ' NOTE: the ColumnSize property needs to be set only for
- ' levels that have string members
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 14 ' the longest member ("Non_Consumable")
- ' they can fit in 14 characters
-
- ' specify how should the level members be ordered
- ' we want the members ordered by Name
- dsoLevel.Ordering = orderName
-
-
- '
- ' create the Product Category level
- ' this level contains all of the product categories
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Product Category")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "product_category" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "product_class" & sRQuote & "." & _
- sLQuote & "product_category" & sRQuote
-
- ' there are 47 distinct categories in the "time_by_day" table
- ' (note that 'Dairy' shows up under both Food and Drinks product families)
- ' NOTE: you can use the following query to find out
- ' the number of distinct members
- ' SELECT DISTINCT product_class.product_family,
- ' product_class.product_category
- ' FROM product_class, product
- ' WHERE product_class.product_class_id = product.product_class_id
- '
- dsoLevel.EstimatedSize = 47
-
- ' this level DOES NOT contains unique members because
- ' 'Dairy' shows up under both Food and Drinks product families
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 50 ' 50 characters should do it
-
- ' we want the categories ordered by Name
- dsoLevel.Ordering = orderName
-
-
- '
- ' create the Brand Name level
- ' this level contains all of the brand names
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Brand Name")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "brand_name" column contains members for this level
- dsoLevel.MemberKeyColumn = sLQuote & "product" & sRQuote & "." & _
- sLQuote & "brand_name" & sRQuote
-
- ' there are 276 distinct brands
- ' NOTE: you can use the following query to
- ' count the distinct members for this level
- ' SELECT DISTINCT product_class.product_family,
- ' product_class.product_category,
- ' product.brand_name
- ' FROM product_class, product
- ' WHERE product_class.product_class_id = product.product_class_id
- '
- dsoLevel.EstimatedSize = 276
-
- ' this level DOES NOT contain unique members, because
- ' BBB Best appears both under the Hot Beverages and Baking Goods categories
- dsoLevel.IsUnique = False
-
- ' DSO needs to know what is the type and maximum size of the members keys
- dsoLevel.ColumnType = adChar
- dsoLevel.ColumnSize = 20 ' no brand name is longer
- ' than 20 characters
-
- ' we want the brands ordered by name
- dsoLevel.Ordering = orderName
-
-
- '
- ' create the Product Name level
- ' this level contains all of the brand names
- On Error GoTo Err_Create
- Set dsoLevel = dsoDimension.Levels.AddNew("Product Name")
-
- ' set the level type
- dsoLevel.LevelType = levRegular
-
- ' "product_id" column contains member keys for this level
- dsoLevel.MemberKeyColumn = sLQuote & "product" & sRQuote & "." & _
- sLQuote & "product_id" & sRQuote
-
- ' we will use the "product_name" column for member names
- dsoLevel.MemberNameColumn = sLQuote & "product" & sRQuote & "." & _
- sLQuote & "product_name" & sRQuote
-
- ' there are 1560 distinct products
- ' NOTE: you can use the following query to
- ' count the distinct members for this level
- ' SELECT DISTINCT product_class.product_family,
- ' product_class.product_category,
- ' product.brand_name,
- ' product_id
- ' FROM product_class, product
- ' WHERE product_class.product_class_id = product.product_class_id
- '
- dsoLevel.EstimatedSize = 1560
-
- ' this level contains unique members
- dsoLevel.IsUnique = True
-
- ' DSO needs to know what is the type of the members keys
- dsoLevel.ColumnType = adInteger
-
- ' we want the brands ordered by name
- dsoLevel.Ordering = orderName
-
- ' create the Low Fat member property for this level
- Dim dsoMemberProperty As DSO.MemberProperty
- Set dsoMemberProperty = dsoLevel.MemberProperties.AddNew("Low Fat")
- dsoMemberProperty.SourceColumn = sLQuote & "product" & sRQuote & "." & _
- sLQuote & "low_fat" & sRQuote
-
- ' save the dimension definition in the metadata repository
- On Error GoTo Err_Update
- dsoDimension.Update
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the dimension definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO dimension object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create dimension Product failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateRole - create a role in the database
- ' Role is a group of users with the same
- ' access privileges
- Public Sub CreateRole()
- ' create the role in the database's
- ' Roles collection
- On Error GoTo Err_Create
- Dim dsoRole As DSO.Role
- Set dsoRole = m_dsoDatabase.Roles.AddNew("Everyone")
-
- ' set the semi-colon separated list of users who belong to this role
- ' make sure that the users are valid NT users, otherwise DSO will
- ' raise an error
- ' format: <domain name>\<user name>[;<domain name>\<user name>...]
- dsoRole.UsersList = "Everyone"
-
- ' save the role definition in the metadata repository
- On Error GoTo Err_Update
- dsoRole.Update
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the role definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO role object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create role Everyone failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateCube - create the Sales cube
- '
- '
- Public Sub CreateCube()
- ' create the Sales cube in the database's
- ' MDStores collection
- On Error GoTo Err_Create
- Dim dsoCube As DSO.MDStore
- Set dsoCube = m_dsoDatabase.MDStores.AddNew("Sales")
-
- ' set the cube's description
- dsoCube.Description = "The Sales cube"
-
- ' set the cube's datasource
- ' use the datasource that was created in the database's Datasources collection
- dsoCube.DataSources.Add m_dsoDatabase.DataSources("Foodmart Sample Database")
-
- ' get the quoting characters from the datasource
- Dim sLQuote As String, sRQuote As String
- sLQuote = dsoCube.DataSources(1).OpenQuoteChar
- sRQuote = dsoCube.DataSources(1).CloseQuoteChar
-
- ' set the source table (fact table) for the cube
- dsoCube.SourceTable = sLQuote & "sales_fact_1998" & sRQuote
-
- ' set the number of rows from the fact table that will be included in the cube
- ' since we want the whole table (we did not specify anything for SourceTableFilter)
- ' we can obtain this number by doing SELECT COUNT(*) FROM sales_fact_1998
- dsoCube.EstimatedRows = 164558
-
- ' specify access permissions to the cube by adding roles to the cube
- ' we will add the role that we have created in the database
- ' and allow users in that role to have both read and write access to the cube
- Dim dsoCubeRole As DSO.Role
- Set dsoCubeRole = dsoCube.Roles.AddNew("Everyone")
- dsoCubeRole.SetPermissions "Access", "RW"
-
- '
- ' create cube's measures
- '
- Dim dsoMeasure As DSO.Measure
-
- ' create a measure for Store Sales
- Set dsoMeasure = dsoCube.Measures.AddNew("Store Sales")
-
- ' set the measure's source column, data type and the formatting
- dsoMeasure.SourceColumn = dsoCube.SourceTable & "." & _
- sLQuote & "store_sales" & sRQuote
- dsoMeasure.SourceColumnType = adDouble
- dsoMeasure.FormatString = "Currency"
-
- ' this measure will be aggregated by summation
- dsoMeasure.AggregateFunction = aggSum
-
-
- ' create a measure for Store Cost
- Set dsoMeasure = dsoCube.Measures.AddNew("Store Cost")
-
- ' set the measure's source column, data type and the formatting
- dsoMeasure.SourceColumn = dsoCube.SourceTable & "." & _
- sLQuote & "store_cost" & sRQuote
- dsoMeasure.SourceColumnType = adDouble
- dsoMeasure.FormatString = "Currency"
-
- ' this measure will be aggregated by summation
- dsoMeasure.AggregateFunction = aggSum
-
- ' create a measure for Sales Count
- ' Sales Count will be the number of all products sold
- Set dsoMeasure = dsoCube.Measures.AddNew("Sales Count")
-
- ' set the measure's source column, data type and the formatting
- dsoMeasure.SourceColumn = dsoCube.SourceTable & "." & _
- sLQuote & "product_id" & sRQuote
- dsoMeasure.SourceColumnType = adInteger
- dsoMeasure.FormatString = "Standard"
-
- ' this measure will be aggregated by counting
- dsoMeasure.AggregateFunction = aggCount
-
-
- ' create a measure for Store Profit
- ' Profit = Sales - Cost
- Set dsoMeasure = dsoCube.Measures.AddNew("Store Profit")
-
- ' set the measure's source column, data type and the formatting
- dsoMeasure.SourceColumn = dsoCube.SourceTable & "." & _
- sLQuote & "store_sales" & sRQuote & _
- " - " & _
- dsoCube.SourceTable & "." & _
- sLQuote & "store_cost" & sRQuote
-
- dsoMeasure.SourceColumnType = adDouble
- dsoMeasure.FormatString = "Currency"
-
- ' this measure will be aggregated by summation
- dsoMeasure.AggregateFunction = aggSum
-
-
- '
- ' add dimensions to the cube
- '
-
- ' add the Product dimension
- ' note that by adding the dimension to the cube
- ' all of the dimension levels are automatically inherited from
- ' the corresponding database dimension
- ' Note: If you do not intend to refer to the newly added cube
- ' dimension, you don't need to declare a variable and instead call
- ' dsoCube.Dimensions.AddNew <dimensionname>
- ' as a Sub.
- Dim dsoProductCubeDim As DSO.Dimension
- Set dsoProductCubeDim = dsoCube.Dimensions.AddNew("Product")
-
- ' add the Time dimension
- Dim dsoTimeCubeDim As DSO.Dimension
- Set dsoTimeCubeDim = dsoCube.Dimensions.AddNew("Time")
-
- ' add the Store dimension
- Dim dsoStoreCubeDim As DSO.Dimension
- Set dsoStoreCubeDim = dsoCube.Dimensions.AddNew("Store")
-
- ' get the list of all tables used in this cube
- ' this list includes the fact table and the dimension tables
- ' Note: Make sure that you do not repeat the same table name twice.
- dsoCube.FromClause = dsoCube.SourceTable & ", " & _
- dsoStoreCubeDim.FromClause & ", " & _
- dsoTimeCubeDim.FromClause & ", " & _
- dsoProductCubeDim.FromClause
-
- ' define the joins between tables used by the cube
-
- ' first define the join between the fact table and the Store table
- dsoCube.JoinClause = _
- "(" & _
- sLQuote & "sales_fact_1998" & sRQuote & "." & sLQuote & "store_id" & sRQuote & _
- " = " & _
- sLQuote & "store" & sRQuote & "." & sLQuote & "store_id" & sRQuote & _
- ")"
-
- ' define the join between the fact table and the Time table
- dsoCube.JoinClause = dsoCube.JoinClause & " AND " & _
- "(" & _
- sLQuote & "sales_fact_1998" & sRQuote & "." & sLQuote & "time_id" & sRQuote & _
- " = " & _
- sLQuote & "time_by_day" & sRQuote & "." & sLQuote & "time_id" & sRQuote & _
- ")"
-
- ' define the join between the fact table and the Product table
- dsoCube.JoinClause = dsoCube.JoinClause & " AND " & _
- "(" & _
- sLQuote & "sales_fact_1998" & sRQuote & "." & sLQuote & "product_id" & sRQuote & _
- " = " & _
- sLQuote & "product" & sRQuote & "." & sLQuote & "product_id" & sRQuote & _
- ")"
-
- ' finally define the join between the Product table and the Product_class table
- dsoCube.JoinClause = dsoCube.JoinClause & " AND " & _
- "(" & _
- sLQuote & "product" & sRQuote & "." & sLQuote & "product_class_id" & sRQuote & _
- " = " & _
- sLQuote & "product_class" & sRQuote & "." & sLQuote & "product_class_id" & sRQuote & _
- ")"
-
- ' save the cube definition in the metadata repository
- On Error GoTo Err_Update
- dsoCube.Update
-
- ' store the reference to the cube object
- ' so that other methods can use it
- Set m_dsoCube = dsoCube
-
- Exit Sub
-
- Err_Create:
- ' Failed to create the object.
- ' Possible reasons:
- ' - the DSO database object is being locked by another DSO application
- ' a DSO object is locked while AddNew method is executing on
- ' one of its collections (Datasources, MDStores, Dimensions...)
- ' - the metadata repository is unreachable
-
- Err_Update:
- ' Failed to persist the cube definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO cube object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Create cube Sales failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' CreateAggregations - design aggregations for the cube
- '
- Public Sub CreateAggregations()
- ' aggregations are designed per partition
- ' get the default partition from the cube
- Dim dsoPartition As DSO.MDStore
- Set dsoPartition = m_dsoCube.MDStores(1)
-
- ' first we need to set the storage mode of the partition
- ' we will set it to MOLAP
- ' (facts and aggregations are loaded into multidimensional structures on
- ' the OLAP server)
- dsoPartition.OlapMode = olapmodeMolapIndex
-
- ' get the partition analyzer
- Dim dsoPartitionAnalyzer As DSO.PartitionAnalyzer
- Set dsoPartitionAnalyzer = dsoPartition.Analyzer
-
- ' initialize the analyzer
- dsoPartitionAnalyzer.InitializeDesign
-
- ' we will design aggregations for 20% of queries
- ' NextAnalysisStep incrementaly builds the optimal set of aggregations
- ' we will stop when PercentageBenefit reaches 20
- Dim PercentageBenefit As Double
- Dim AccumulatedSize As Double
- Dim AggregationsCount As Long
- Do While dsoPartitionAnalyzer.NextAnalysisStep(PercentageBenefit, _
- AccumulatedSize, _
- AggregationsCount)
- If PercentageBenefit > 20# Then
- ' Reached 20% optimization.
- Exit Do
- End If
- Loop
-
- ' apply the designed aggregations to the partition
- Dim dsoAggregation As DSO.MDStore
- For Each dsoAggregation In dsoPartitionAnalyzer.DesignedAggregations
- dsoPartition.MDStores.Add dsoAggregation
- Next
-
- ' close the analyzer
- dsoPartitionAnalyzer.CloseAggregationsAnalysis
-
- ' save the partition definition in the metadata repository
- On Error GoTo Err_Update
- dsoPartition.Update
-
- Exit Sub
-
- Err_Update:
- ' Failed to persist the cube definition in the metadata repository
- ' Possible reasons:
- ' - the metadata repository is unreachable
- ' you can see where the metadata repository resides by looking
- ' up the following registry entry:
- ' HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
- ' Repository Connection String
- ' - the DSO cube object is being locked by another DSO application
- ' it is not possible for two DSO apps to persist the same object
- ' at the same time
- ' it is not possible to persist a DSO object, it another DSO app
- ' has explicitly locked it
-
- MsgBox "Design aggregations for Partition failed" & vbCrLf & Err.Description
- End Sub
-
-
- '
- ' ProcessDatabase - processes the whole DSO database
- '
- Public Sub ProcessDatabase()
- On Error GoTo Err_Process
-
- ' Note, although processing the whole database could
- ' have been done with a single call:
- ' m_dsoDatabase.Process
- ' The function outlines the individual calls that are made
- ' to process dimensions and cubes within a single transaction
-
- ' Begin transaction
- m_dsoDatabase.BeginTrans
-
- ' Process all of the dimensions
- Dim dsoDim As DSO.Dimension
- For Each dsoDim In m_dsoDatabase.Dimensions
- dsoDim.Process processFull
- Next
-
- ' Process the cube (the first and only).
- Dim dsoCube As DSO.MDStore
- Set dsoCube = m_dsoDatabase.MDStores(1)
- dsoCube.Process processFull
-
- ' Commit the transaction
- m_dsoDatabase.CommitTrans
-
-
-
- Exit Sub
-
- Err_Process:
- ' Processing of the database failes.
- ' Possible reasons:
- ' - OLAP server is not running or unreachable
- ' - connection to the relational data source cannot be established
- ' - cube or dimensions are not properly defined
- ' - another app is processing one of the cubes or dimensions from this
- ' database
- ' - another app has locked one of the cubes or dimensions from this
- ' database
-
- ' Rollback the transaction in case of failure.
- m_dsoDatabase.Rollback
-
- MsgBox "Process database failed" & vbCrLf & Err.Description
-
- End Sub
-